<template>
  <div class="app-container form_body2">

<el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
        <el-tag style="margin-left:20px;">*请在技术指导下修改信息，确保不发生错误！</el-tag>
      <div class='hrinfo_box'></div>
  <el-form-item label="模版ID" prop="tmpid">
    <el-input v-model="ruleForm.tmpid"></el-input>
  </el-form-item>
  
  <el-form-item label="第一个值" prop="value1">
    <el-input v-model="ruleForm.value1"></el-input>
  </el-form-item>
 
  <el-form-item label="第二个值" prop="value2">
    <el-input v-model="ruleForm.value2"></el-input>
  </el-form-item>
    <el-form-item label="第三个值" prop="value3">
    <el-input v-model="ruleForm.value3"></el-input>
  </el-form-item>
    <el-form-item label="第四个值" prop="value4">
    <el-input v-model="ruleForm.value4"></el-input>
  </el-form-item>
    <el-form-item label="第五个值" prop="value5">
    <el-input v-model="ruleForm.value5"></el-input>
  </el-form-item>
 
  <el-form-item>
    <el-button type="primary" @click="submitForm('ruleForm')">立即保存</el-button>
    <!-- <el-button @click="resetForm('ruleForm')">重置</el-button> -->
  </el-form-item>
</el-form>
  </div>
</template>
<script>
export default {
  data() {
    return {
      ruleForm: {

      },
      rules: {
        tempid: [
          {
            required: true,
            min: 2,
            max: 255,
            message: '请输入模版ID',
            trigger: 'blur'
          },
          {
            min: 3,
            max: 255,
            message: '长度在 2 到 255 个字符',
            trigger: 'blur'
          }
        ]
      }
    }
  },

  mounted() {
    this.gettmp()
  },
  methods: {

    gettmp() {
      var that = this
      that
        .$request({
          url: '/admin/gettmp',
          method: 'post'
        })
        .then(res => {
          console.log(res)
          if (res.code == 200) {
            that.ruleForm = res.data
          }
        })
    },
    submitForm(formName) {
      var that = this

      this.$refs[formName].validate(valid => {
        if (valid) {
          const data = that.ruleForm
          that
            .$request({
              url: '/admin/updatetmp',
              method: 'post',
              data
            })
            .then(res => {
              if (res.code == 200) {
                that.$message({ message: '修改成功!', type: 'success' })
                that.gettmp()
              }
            })
        } else {
          console.log('error submit!!')
          return false
        }
      })
    },
    resetForm(formName) {
      this.$refs[formName].resetFields()
    }
  }
}
</script>
<style  scode>
.form_body2 {
  width: 420px;
  height: auto;
}
.hrinfo_box{
    height: 20px;
    width: 100%;
}
</style>
